package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
 import com.muyu.danmo.domain.DanmoPicture;
import com.muyu.danmo.service.IDanmoPictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 照片Controller
 * 
 * @author kunzong
 * @date 2024-12-21
 */
@RestController
@RequestMapping("/danmoPicture")
public class DanmoPictureController extends BaseController
{
    @Autowired
    private IDanmoPictureService danmoPictureService;

    /**
     * 查询照片列表
     */
//    @RequiresPermissions("system:DanmoPicture:list")
    @GetMapping("/list")
    public Result list(DanmoPicture danmoPicture)
    {
        List<DanmoPicture> list = danmoPictureService.selectDanmoPictureList(danmoPicture);
        return Result.success(list);
    }

    /**
     * 导出照片列表
     */
//    @RequiresPermissions("system:DanmoPicture:export")
    @Log(title = "照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoPicture danmoPicture)
    {
        List<DanmoPicture> list = danmoPictureService.selectDanmoPictureList(danmoPicture);
        ExcelUtil<DanmoPicture> util = new ExcelUtil<DanmoPicture>(DanmoPicture.class);
        util.exportExcel(response, list, "照片数据");
    }

    /**
     * 获取照片详细信息
     */
//    @RequiresPermissions("system:DanmoPicture:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(danmoPictureService.selectDanmoPictureById(id));
    }

    /**
     * 新增照片
     */
//    @RequiresPermissions("system:DanmoPicture:add")
    @Log(title = "照片", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoPicture danmoPicture)
    {
        return Result.success(danmoPictureService.insertDanmoPicture(danmoPicture));
    }

    /**
     * 修改照片
     */
//    @RequiresPermissions("system:DanmoPicture:edit")
    @Log(title = "照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoPicture danmoPicture)
    {
        return Result.success(danmoPictureService.updateDanmoPicture(danmoPicture));
    }

    /**
     * 删除照片
     */
//    @RequiresPermissions("system:DanmoPicture:remove")
    @Log(title = "照片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.success(danmoPictureService.deleteDanmoPictureByIds(ids));
    }
}
